package com.spark.util.example

import com.spark.util.client.KafkaProducerClient
import com.spark.util.utils.PropertiesUtil
import java.util.Properties

object KafkaExample {

  def main(args: Array[String]): Unit = {

    PropertiesUtil.load("dev.properties")
    val bootstrap = PropertiesUtil.getString("kafka.bootstrap.server")
    val props = new Properties()
    props.setProperty("bootstrap.servers", bootstrap)
    props.setProperty("key.serializer", "org.apache.kafka.common.serialization.StringSerializer")
    props.setProperty("value.serializer", "org.apache.kafka.common.serialization.StringSerializer")
    val kafkaSink = KafkaProducerClient[String,String](props)
    // 往kafka写消息
    kafkaSink.send("dff_test", "test")
  }
}
